<?php
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
define('BP', dirname(dirname(__FILE__)));
$appPath = dirname(__FILE__);
set_include_path(
	get_include_path().PS.
	BP.DS.'ez'.PS.
	$appPath.DS.'controllers'.PS.
	$appPath.DS.'block'.PS.
	$appPath.DS.'helper'.PS.
	$appPath.DS.'model'
	);

require_once 'ez_Router.php';
require_once 'ez_Abstract.php';
require_once 'ez_FrontAbstract.php';
require_once 'ez_Controller.php';
require_once 'ez_Block.php';

require_once ('config.php');
require_once ('PageController.php');
$router = new ez_Router();
$router->setUrlSuffix(substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])+1));
//echo substr($_SERVER['PHP_SELF'],strlen($_SERVER['SCRIPT_NAME'])+1);
$controllerName = $router->getController();
$actionName = $router->getAction();
$parameters = $router->getParameters();
require_once ($controllerName.'Controller.php');
$controllerRef = new ReflectionClass($controllerName.'Controller');
$actionRef = $controllerRef->getMethod($actionName.'Action');
$c = $controllerRef->newInstance();
$c->setControllerName($controllerName);
$c->setActionName($actionName);
$c->setBaseUrl($baseurl);
$c->setAppPath($appPath);
$c->setParameters($parameters);
$actionRef->invoke($c);

class ez
{
	public static function getAppPath()
	{
		return dirname(__FILE__).DS;
	}
	
	public static function getBaseUrl()
	{
		return Config::getConfig('baseurl');
	}
}